#!/bin/sh
# -*- coding: utf-8 -*-

### BEGIN INIT INFO
# Provides:          pthelper
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 6
### END INIT INFO



WORKPATH=/home/qiang/PT-helper
DAEMON=./main.py

start()
{
  cd $WORKPATH && $DAEMON &
}

stop()
{
  ps aux|grep main.py|awk '{print $2}'|xargs kill -9
}

case "$1" in
  start)
    start
  ;;
  stop)
    stop
  ;;
  restart)
    stop
    start
  ;;
  *)
    echo "Usage: /etc/init.d/$NAME {start|stop|restart}" >&2
    exit 2
  ;;
esac
